<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-9-18
 * Time: 下午4:07
 */
$txt = '<result><status><![CDATA[1]]></status><msg><![CDATA[录入订单成功！本订单需要在线支付后才能有效！]]></msg><error_state>10000</error_state><error_msg><![CDATA[录入订单成功！本订单需要在线支付后才能有效！]]></error_msg><order_id><![CDATA[4566484]]></order_id><order_money><![CDATA[23]]></order_money><order_state><![CDATA[1]]></order_state></result>';
$result = simplexml_load_string( $txt, 'SimpleXMLElement', LIBXML_NOCDATA );
$order_id = (string)$result->order_id;
$url ='http://u.dgkangfei.com/api/pay.jsp';
$arr['custId'] ='291009';
$arr['apikey']='E885A0E22E64EB8D38CC7338407E997B';
$arr['orderId']=$order_id;
$result = curl($url,$arr,$type = 'get');
 function curl($url, $data , $type = 'get') {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if ($type == 'post') {
        $req = http_build_query($data);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    } else {
        if (!empty($data)) {
            $url = $url . '?' . http_build_query($data);
            $url = urldecode($url);
            echo $url;
        }
        curl_setopt($ch, CURLOPT_URL,$url );
    }
    if (substr($url, 0, 5) == 'https') {
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    }
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}
print_r($result);
logfile($result,'/var/www/html/new/d/module/qkxproject/api/ziwoyou/ziwoyou_get_data.txt');
function logfile($txt, $path)
{
    $fp = fopen($path, "a");
    flock($fp, LOCK_EX);
    fwrite($fp, $txt . "\n");
    flock($fp, LOCK_UN);
    fclose($fp);
}